<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Sets the ISO date</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="datetime.setdate.html">DateTime::setDate</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="datetime.settime.html">DateTime::setTime</a></div>
 <div class="up"><a href="class.datetime.html">DateTime</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="datetime.setisodate" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">DateTime::setISODate</h1>
  <h1 class="refname">date_isodate_set</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.2.0)</p><p class="refpurpose"><span class="refname">DateTime::setISODate</span> -- <span class="refname">date_isodate_set</span> &mdash; <span class="dc-title">Sets the ISO date</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-datetime.setisodate-description">
  <h3 class="title">说明</h3>
  <p class="para">面向对象风格</p>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type"><a href="class.datetime.html" class="type DateTime">DateTime</a></span> <span class="methodname"><strong>DateTime::setISODate</strong></span>
    ( <span class="methodparam"><span class="type">int</span> <code class="parameter">$year</code></span>
   , <span class="methodparam"><span class="type">int</span> <code class="parameter">$week</code></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$day</code><span class="initializer"> = 1</span></span>
  ] )</div>

  <p class="para rdfs-comment">过程化风格</p>
  <div class="methodsynopsis dc-description">
   <span class="type"><a href="class.datetime.html" class="type DateTime">DateTime</a></span> <span class="methodname"><a href="function.date-isodate-set.html" class="methodname">date_isodate_set</a></span>
    ( <span class="methodparam"><span class="type"><a href="class.datetime.html" class="type DateTime">DateTime</a></span> <code class="parameter">$object</code></span>
   , <span class="methodparam"><span class="type">int</span> <code class="parameter">$year</code></span>
   , <span class="methodparam"><span class="type">int</span> <code class="parameter">$week</code></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$day</code><span class="initializer"> = 1</span></span>
  ] )</div>

  <p class="para rdfs-comment">
   Set a date according to the ISO 8601 standard - using weeks and day offsets
   rather than specific dates.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-datetime.setisodate-parameters">
  <h3 class="title">参数</h3>
  <dl>

   <dt>
<em><code class="parameter">object</code></em></dt>

<dd>
<p class="para">仅过程化风格：由 <span class="function"><a href="function.date-create.html" class="function">date_create()</a></span> 返回的 <a href="class.datetime.html" class="classname">DateTime</a> 类型的对象。此函数会修改这个对象。</p></dd>

   
    <dt>
<em><code class="parameter">year</code></em></dt>

    <dd>

     <p class="para">
      Year of the date.
     </p>
    </dd>

   
   
    <dt>
<em><code class="parameter">week</code></em></dt>

    <dd>

     <p class="para">
      Week of the date.
     </p>
    </dd>

   
   
    <dt>
<em><code class="parameter">day</code></em></dt>

    <dd>

     <p class="para">
      Offset from the first day of the week.
     </p>
    </dd>

   
  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-datetime.setisodate-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   返回被修改的 DateTime 对象， 或者在失败时返回 <strong><code>FALSE</code></strong>.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-datetime.setisodate-changelog">
  <h3 class="title">更新日志</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>版本</th>
      <th>说明</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr><td>5.3.0</td><td>将返回值从<strong><code>NULL</code></strong>改为 <a href="class.datetime.html" class="classname">DateTime</a> 类型。</td></tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-datetime.setisodate-examples">
  <h3 class="title">范例</h3>
  <div class="example" id="example-2196">
   <p><strong>Example #1 <span class="function"><strong>DateTime::setISODate()</strong></span> example</strong></p>
   <div class="example-contents"><p>面向对象风格</p></div>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$date&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">DateTime</span><span style="color: #007700">();<br /><br /></span><span style="color: #0000BB">$date</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">setISODate</span><span style="color: #007700">(</span><span style="color: #0000BB">2008</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">2</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #0000BB">$date</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">format</span><span style="color: #007700">(</span><span style="color: #DD0000">'Y-m-d'</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$date</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">setISODate</span><span style="color: #007700">(</span><span style="color: #0000BB">2008</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">2</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">7</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #0000BB">$date</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">format</span><span style="color: #007700">(</span><span style="color: #DD0000">'Y-m-d'</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

   <div class="example-contents"><p>过程化风格</p></div>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$date&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">date_create</span><span style="color: #007700">();<br /><br /></span><span style="color: #0000BB">date_isodate_set</span><span style="color: #007700">(</span><span style="color: #0000BB">$date</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">2008</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">2</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #0000BB">date_format</span><span style="color: #007700">(</span><span style="color: #0000BB">$date</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'Y-m-d'</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">date_isodate_set</span><span style="color: #007700">(</span><span style="color: #0000BB">$date</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">2008</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">2</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">7</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #0000BB">date_format</span><span style="color: #007700">(</span><span style="color: #0000BB">$date</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'Y-m-d'</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

   <div class="example-contents"><p>以上例程会输出：</p></div>
   <div class="example-contents screen">
<div class="cdata"><pre>
2008-01-07
2008-01-13
</pre></div>
   </div>
  </div>
  <div class="example" id="example-2197">
   <p><strong>Example #2 Values exceeding ranges are added to their parent values</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$date&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">DateTime</span><span style="color: #007700">();<br /><br /></span><span style="color: #0000BB">$date</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">setISODate</span><span style="color: #007700">(</span><span style="color: #0000BB">2008</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">2</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">7</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #0000BB">$date</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">format</span><span style="color: #007700">(</span><span style="color: #DD0000">'Y-m-d'</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$date</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">setISODate</span><span style="color: #007700">(</span><span style="color: #0000BB">2008</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">2</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">8</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #0000BB">$date</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">format</span><span style="color: #007700">(</span><span style="color: #DD0000">'Y-m-d'</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$date</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">setISODate</span><span style="color: #007700">(</span><span style="color: #0000BB">2008</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">53</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">7</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #0000BB">$date</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">format</span><span style="color: #007700">(</span><span style="color: #DD0000">'Y-m-d'</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

   <div class="example-contents"><p>以上例程会输出：</p></div>
   <div class="example-contents screen">
<div class="cdata"><pre>
2008-01-13
2008-01-14
2009-01-04
</pre></div>
   </div>
  </div>
  <div class="example" id="example-2198">
   <p><strong>Example #3 Finding the month a week is in</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$date&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">DateTime</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$date</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">setISODate</span><span style="color: #007700">(</span><span style="color: #0000BB">2008</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">14</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #0000BB">$date</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">format</span><span style="color: #007700">(</span><span style="color: #DD0000">'n'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

   <div class="example-contents"><p>以上例程会输出：</p></div>
   <div class="example-contents screen">
<div class="cdata"><pre>
3
</pre></div>
   </div>
  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-datetime.setisodate-seealso">
  <h3 class="title">参见</h3>
  <ul class="simplelist">
   <li class="member"><span class="function"><a href="datetime.setdate.html" class="function" rel="rdfs-seeAlso">DateTime::setDate()</a> - Sets the date</span></li>
   <li class="member"><span class="function"><a href="datetime.settime.html" class="function" rel="rdfs-seeAlso">DateTime::setTime()</a> - Sets the time</span></li>
  </ul>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="datetime.setdate.html">DateTime::setDate</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="datetime.settime.html">DateTime::setTime</a></div>
 <div class="up"><a href="class.datetime.html">DateTime</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
